package com.beehoo.dcportal.dao.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.beehoo.dcportal.common.base.BaseDao;
import com.beehoo.dcportal.common.base.BaseException;
import com.beehoo.dcportal.dao.IBusinessDao;
import com.beehoo.dcportal.model.BusinessBean;

public class BusinessDaoImpl extends BaseDao implements IBusinessDao {

	private static final Logger logger = Logger.getLogger(BusinessDaoImpl.class);
	
	@SuppressWarnings("unchecked")
	@Override
	public List<BusinessBean> queryBusiness(Map<String, Object> paramMap)
			throws BaseException {
		List<BusinessBean> businessLs = null;
		try {
			businessLs = getSqlMapClient().queryForList("portal-business.queryBusiness", paramMap);
			logger.info("商户查询-查询|#[查询内容："+paramMap.get("condition")+"],成功!");
		} catch (SQLException e) {
			logger.error("商户查询-查询|#[查询内容："+paramMap.get("condition")+"],失败!异常："+e.getMessage());
			throw new BaseException(e,"custom.messages.error.business.query.error");
		}
		return businessLs;
	}

	@Override
	public int queryBusinessCount(Map<String, Object> paramMap)
			throws BaseException {
		int total = 0;
		try {
			total = (Integer) getSqlMapClient().queryForObject("portal-business.queryBusinessCount", paramMap);
			logger.info("商户查询-查询总数|#[查询内容："+paramMap.get("condition")+"],成功!");
		} catch (SQLException e) {
			logger.error("商户查询-查询总数|#[查询内容："+paramMap.get("condition")+"],失败!异常："+e.getMessage());
			throw new BaseException(e,"custom.messages.error.business.query.error");
		}
		return total;
	}

}
